/*
 * Player.cpp
 *
 *  Created on: 23.06.2012
 *      Author: sebastian
 */

#include "Player.h"

#include <stdlib.h> //for rand
#include <time.h>
#include <string>
#include "../utils/utils.h"

#include "../Game.h"

using namespace std;

Player::Player(std::string name)
:Namable::Namable(name) {

	points_ = 0;

	//...generate startplanet.
	startPlanet_ = new Planet();

	planets_.push_back(startPlanet_);


	sessionID_ = -1;

	g_pGame->getUniverse()->addPhysicalObject(startPlanet_);
}

void Player::connectTo(const std::string &IP) {
	currenIP_ = IP;
	//generating sesionid //TODO make them unique!!?
	sessionID_ = rand()+1; //wollen nicht 0 als sessid
	DmLog("connected Player with sessid "+intToStr(sessionID_));

}

Player::~Player() {
	// TODO Auto-generated destructor stub
}

std::string Player::getCurrenIP() const
{
	return currenIP_;
}

std::string Player::getPassword() const
{
	return password;
}

int Player::getPoints() const
{
	return points_;
}

int Player::getSessionID() const
{
	return sessionID_;
}

Planet * Player::getStartPlanet() const
{
	return startPlanet_;
}

const std::list<Planet*>& Player::getPlanets() const
{
	return planets_;
}

void Player::setPassword(std::string password)
{
	this->password = password;
}

void Player::setPoints(int points_)
{
	this->points_ = points_;
}

void Player::setSessionID(int sessionID_)
{
	this->sessionID_ = sessionID_;
}
